package logic

import (
	"context"
	"go.uber.org/zap"
	"homepage_srv/homepage"
	"homepage_srv/internal/dao"
	"homepage_srv/internal/svc"
	"smart-health-platforms/pkg"

	"github.com/zeromicro/go-zero/core/logx"
)

type CartListLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewCartListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CartListLogic {
	return &CartListLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *CartListLogic) CartList(in *homepage.CartListRequest) (*homepage.CartListResponse, error) {
	// todo: add your logic here and delete this line
	list, err := dao.CartList(int(in.UserId))
	if err != nil {
		pkg.Error("列表展示失败", zap.Error(err))
		return nil, err
	}
	return &homepage.CartListResponse{List: list}, nil
}
